-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a 'Create Badge' function for users #670
Provide a 'Create Badge' function for users #670
Conversation
I contributed slightly broken versions of these in scalacenter#660
The markdown required to create a badge is fairly verbose: ``` [![algebra-laws Scala version support](https://index.scala-lang.org/typelevel/algebra/algebra-laws/latest-by-scala-version.svg)](https://index.scala-lang.org/typelevel/algebra/algebra-laws) ``` ...it's nice to be able to help people to create it. Travis CI, GitHub and others follow this pattern to show both the badge, and the recommended markdown to display it.
visibility: hidden; | ||
opacity: 0; | ||
} | ||
.overlay:target { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is using the 'Pure-CSS lightbox' technique to create a modal overlay without any javascript:
https://developer.mozilla.org/en-US/docs/Web/CSS/:target#pure-css_lightbox
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice too!
@@ -14,6 +14,10 @@ main { | |||
flex: 1; | |||
} | |||
|
|||
.copyable-incantation { | |||
user-select: all; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has the nice effect of the user selecting the entire text sample, rather just a word, when they click on it - at that point it's very easy to copy & paste the entire expression, so it's a nice complement (or possibly even replacement) to the Javascript 'Copy' button.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice trick!
Thanks for this contribution, that's a really nice idea! I have deployed this PR on the dev server for testing: https://index-dev.scala-lang.org/ A few remarks about the end result:
|
Suggested in scalacenter#670 (comment) ...not entirely sure if it's better there, especially as the available space is even more narrow.
So if we're looking at: https://index.scala-lang.org/typelevel/cats/cats-core/2.6.1?target=_sjs1.x_3.x ...we want to see the badge with `targetType=js`, rather than the default badge that displays JVM-based artifacts.
1656f4d
to
3e7498e
Compare
Suggested in scalacenter#670 (comment) ...not entirely sure if it's better there, especially as the available space is even more narrow.
Hi @adpi2 , thanks for you feedback! Handling non-JVM artifacts (Scala.JS, sbt, etc)
I've pushed commit 3e7498e, which hopefully goes some way to addressing this. The badge now uses the For ..this isn't really ideal - for ...that's probably a fix for a separate PR tho'. (edit: done in #674) Badge placement
The good news is that it might not be necessary to display multiple badges at once, if the "badge-targetType-matches-the-selected-target" tweak above is acceptable. I wasn't sure if moving the badge to the RHS bar was better - the space is even more narrow, so most of the badge gets lost, and I couldn't find any clean CSS techniques to fade out the right -hand side of the badge to indicate it was truncated. As I wasn't certain about it, I've put that change into a Badge placed in the Project InfoThis does have the advantage of being a wide part of the layout, so we get to see a fair amount of the badge: Badge placed in it's own box on the RHS barThis is unfortunately quite a narrow space - we don't get to see much of the badge: |
New changes deployed: https://index-dev.scala-lang.org/ Handling non-JVM artifacts (Scala.JS, sbt, etc)Looks good to me.
I agree. It can be done in another PR. Badge placementI still think it should be placed on the RHS because:
According to me, this 'Create Badge' section is useful to copy-paste the markdown piece but it should not be placed in the project header, because it would add too much redundancy.
Have you tried |
Suggested in scalacenter#670 (comment) Advantages ---------- * If the project already has the badge in it's project README, then it would be repetitious to show the badge immediately above it in the project header. * If we consider the visible badge on the project page as just a link to the markdown-generator lightbox, rather than informational in itself (given that version information is already visible in the versions dropdown), then there is no need to prominently display the full badge. Disadvantages ------------- * Narrower space usually truncates the (very wide) badge. Mitigating against this is the argument that the badge here is just a link, rather than informational. * Takes up more space vertically, so the consumed screen-area is somewhat larger than with the badge in the project header, even though it's narrower! It would be nice if there was a visual indication that the badge was truncated on the right. Using `overflow: scroll` gives an always-present scrollbar, which I find visually cluttered and more than what's needed- we don't really want to scroll the badge from side-to-side, when we can just click on it to view the whole thing.
Thanks again @rtyley for your contribution! It's deployed in production: https://index.scala-lang.org/ I agree the current placement is not ideal. We, at the Scala Center team, are currenlty thinking of redesigning the project page in different tabs: project tab, and releases tab. With this redesign the version dropdowns will probably go to the release tab, and then we will be able to find a better place for the badge. |
Thanks @adpi2 ! That's cool - I'm on holiday at the moment so wasn't able to respond properly to your feedback, but many thanks for releasing! |
Each release of sbt uses a specific version of Scala (1.0 uses Scala 2.12, 0.13 uses Scala 2.10), so the sbt version of a plugin fully determines the Scala language binary version it uses - this means, for a user, it's only really interesting to know the sbt version of the plugin, not the Scala language version. At the moment, the Scaladex badge for, eg, the `sbt-assembly` plugin reads `1.0.0 (Scala 2.12, 2.10)` - for the user, it would be more helpful if it read `1.0.0 (sbt 1.0, 0.13)` - listing the versions of sbt you can actually use it with! Although the Scaladex badge did have some logic to display platform versions supported by _all_ listed Scala language versions, that didn't help in this situation, as the Scala language version differs for each platform version of sbt. This commit updates the Scaladex badge logic to have two version-summary strategies: * `SummariseLanguageVersion` - which was the existing strategy, listing notable Scala version support, secondarily adding in a summary of platform editions (eg 'JS 1.0+0.6, Native 0.4') scalacenter#670 (comment)
Each release of sbt uses a specific version of Scala (1.0 uses Scala 2.12, 0.13 uses Scala 2.10), so the sbt version of a plugin fully determines the Scala language binary version it uses - this means, for a user, it's only really interesting to know the sbt version of the plugin, not the Scala language version. At the moment, the Scaladex badge for, eg, the `sbt-assembly` plugin reads `1.0.0 (Scala 2.12, 2.10)` - for the user, it would be more helpful if it read `1.0.0 (sbt 1.0, 0.13)` - listing the versions of sbt you can actually use it with! Although the Scaladex badge did have some logic to display platform versions supported by _all_ listed Scala language versions, that didn't help in this situation, as the Scala language version differs for each platform version of sbt. This commit updates the Scaladex badge logic to have two version-summary strategies: * `SummariseLanguageVersion` - which was the existing strategy, listing notable Scala version support, secondarily adding in a summary of platform editions (eg 'Scala 2.13 - Native 0.4+0.3') * `SummarisePlatformEdition` - the new strategy, which is used if *all* fetched `ScalaTarget`s for an artifact have a `targetType` for which the platform version fully determines the Scala version (as is the case for sbt). It omits the Scala version from the summary, and just relates the platform versions (eg `sbt 1.0, 0.13`) scalacenter#670 (comment)
Each release of sbt uses a specific version of Scala (1.0 uses Scala 2.12, 0.13 uses Scala 2.10), so the sbt version of a plugin fully determines the Scala language binary version it uses - this means, for a user, it's only really interesting to know the sbt version of the plugin, not the Scala language version. At the moment, the Scaladex badge for, eg, the `sbt-assembly` plugin reads `1.0.0 (Scala 2.12, 2.10)` - for the user, it would be more helpful if it read `1.0.0 (sbt 1.0, 0.13)` - listing the versions of sbt you can actually use it with! Although the Scaladex badge did have some logic to display platform versions supported by _all_ listed Scala language versions, that didn't help in this situation, as the Scala language version differs for each platform version of sbt. This commit updates the Scaladex badge logic to have two version-summary strategies: * `SummariseLanguageVersion` - which was the existing strategy, listing notable Scala version support, secondarily adding in a summary of platform editions (eg 'Scala 2.13 - Native 0.4+0.3') * `SummarisePlatformEdition` - the new strategy, which is used if *all* fetched `ScalaTarget`s for an artifact have a `targetType` for which the platform version fully determines the Scala version (as is the case for sbt). It omits the Scala version from the summary, and just relates the platform versions (eg `sbt 1.0, 0.13`) scalacenter#670 (comment)
Each release of sbt uses a specific version of Scala (1.0 uses Scala 2.12, 0.13 uses Scala 2.10), so the sbt version of a plugin fully determines the Scala language binary version it uses - this means, for a user, it's only really interesting to know the sbt version of the plugin, not the Scala language version. At the moment, the Scaladex badge for, eg, the `sbt-assembly` plugin reads `1.0.0 (Scala 2.12, 2.10)` - for the user, it would be more helpful if it read `1.0.0 (sbt 1.0, 0.13)` - listing the versions of sbt you can actually use it with! Although the Scaladex badge did have some logic to display platform versions supported by _all_ listed Scala language versions, that didn't help in this situation, as the Scala language version differs for each platform version of sbt. This commit updates the Scaladex badge logic to have two version-summary strategies: * `SummariseLanguageVersion` - which was the existing strategy, listing notable Scala version support, secondarily adding in a summary of platform editions (eg 'Scala 2.13 - Native 0.4+0.3') * `SummarisePlatformEdition` - the new strategy, which is used if *all* fetched `ScalaTarget`s for an artifact have a `targetType` for which the platform version fully determines the Scala version (as is the case for sbt). It omits the Scala version from the summary, and just relates the platform versions (eg `sbt 1.0, 0.13`) scalacenter#670 (comment)
Each release of sbt uses a specific version of Scala (1.0 uses Scala 2.12, 0.13 uses Scala 2.10), so the sbt version of a plugin fully determines the Scala language binary version it uses - this means, for a user, it's only really interesting to know the sbt version of the plugin, not the Scala language version. At the moment, the Scaladex badge for, eg, the `sbt-assembly` plugin reads `1.0.0 (Scala 2.12, 2.10)` - for the user, it would be more helpful if it read `1.0.0 (sbt 1.0, 0.13)` - listing the versions of sbt you can actually use it with! Although the Scaladex badge did have some logic to display the platform versions supported by _all_ listed Scala language versions, that doesn't help in this situation, as the Scala language version differs for each platform version of sbt. This commit updates the Scaladex badge logic to have two version-summary strategies: * `SummariseLanguageVersion` - which was the existing strategy, listing notable Scala version support, secondarily adding in a summary of platform editions (eg 'Scala 2.13 - Native 0.4+0.3') * `SummarisePlatformEdition` - the new strategy, which is used if *all* fetched `ScalaTarget`s for an artifact have a `targetType` for which the platform version fully determines the Scala version (as is the case for sbt). It omits the Scala version from the summary, and just relates the platform versions (eg `sbt 1.0, 0.13`) scalacenter#670 (comment)
Each release of sbt uses a specific version of Scala (1.0 uses Scala 2.12, 0.13 uses Scala 2.10), so the sbt version of a plugin fully determines the Scala language binary version it uses - this means, for a user, it's only really interesting to know the sbt version of the plugin, not the Scala language version. At the moment, the Scaladex badge for, eg, the `sbt-assembly` plugin reads `1.0.0 (Scala 2.12, 2.10)` - for the user, it would be more helpful if it read `1.0.0 (sbt 1.0, 0.13)` - listing the versions of sbt you can actually use it with! Although the Scaladex badge did have some logic to display the platform versions supported by _all_ listed Scala language versions, that doesn't help in this situation, as the Scala language version differs for each platform version of sbt. See also this comment from a prior PR: scalacenter#670 (comment) This commit updates the Scaladex badge logic to have two version-summary strategies: * `SummariseLanguageVersion` - which was the existing strategy, listing notable Scala version support, secondarily adding in a summary of platform editions (eg 'Scala 2.13 - Native 0.4+0.3') * `SummarisePlatformEdition` - the new strategy, which is used if *all* fetched `ScalaTarget`s for an artifact have a `targetType` for which the platform version fully determines the Scala version (as is the case for sbt). It omits the Scala version from the summary, and just relates the platform versions (eg `sbt 1.0, 0.13`)
The 'Create Badge' function was introduced with scalacenter#670, but unfortunately a small typo was introduced with scalacenter#705, removing the closing bracket on the markdown the user will copy - so instead of this: [![play-v28 Scala version support](https://index.scala-lang.org/guardian/play-secret-rotation/play-v28/latest-by-scala-version.svg](https://index.scala-lang.org/guardian/play-secret-rotation/play-v28) ...there's this broken markdown: [![play-v28 Scala version support](https://index.scala-lang.org/guardian/play-secret-rotation/play-v28/latest-by-scala-version.svg](https://index.scala-lang.org/guardian/play-secret-rotation/play-v28
The 'Create Badge' function was introduced with scalacenter#670, but unfortunately a small typo was introduced with scalacenter#705, removing two closing brackets on the markdown the user will copy - so instead of this: [![play-v28 Scala version support](https://index.scala-lang.org/guardian/play-secret-rotation/play-v28/latest-by-scala-version.svg)](https://index.scala-lang.org/guardian/play-secret-rotation/play-v28) ...there's this broken markdown: [![play-v28 Scala version support](https://index.scala-lang.org/guardian/play-secret-rotation/play-v28/latest-by-scala-version.svg](https://index.scala-lang.org/guardian/play-secret-rotation/play-v28
This work follows on from #660 - the markdown required to display a badge is fairly verbose:
...it's nice to be able to help people to create it:
video.mp4
Travis CI, GitHub and others follow this pattern of showing both the badge, and the recommended markdown to display it.
cc @adpi2